/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package ru.vsu.cs.piit.vokod.TableModels;

import javax.swing.JTable;
import javax.swing.ListSelectionModel;
import javax.swing.table.TableModel;
import ru.vsu.cs.piit.vokod.ObservableArrayList;
import ru.vsu.cs.piit.vokod.model.Pacient;

/**
 *
 * @author Галчонок
 */
public class PacientsTable extends JTable {


    public PacientsTable(ObservableArrayList<Pacient> data) {
        super();
        this.setModel(new PacientsTableModel(data));
        this.setRowHeight(this.getRowHeight()+5);
        this.getSelectionModel().setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    }

    @Override
    public PacientsTableModel getModel() {
        return (PacientsTableModel)super.getModel();
    }

    @Override
    public void setModel(TableModel dataModel) {
        if (dataModel instanceof PacientsTableModel)
            super.setModel(dataModel);
        else
            super.setModel(new PacientsTableModel(new ObservableArrayList<Pacient>()));
    }

    public void delCurrentRow()
    {
        getModel().delRow(getSelectedRow());
    }
}
